/* Firefox userChrome.css tweaks ********************************************************/
/* Github: https://github.com/aris-t2/customcssforfx ************************************/
/****************************************************************************************/


:root {
  --tabs_toolbar_color_tabs_not_on_top: linear-gradient(#f9f9fa,#f9f9fa);
  --tab-min-height_tnot: 32px;
  --tab_below_navigation_toolbar_bottom_padding: calc( var(--tab-min-height_tnot) + 5px );
  --tab_below_navigation_toolbar_bottom_padding_macOS: calc( var(--tab-min-height) + 8px );
  --tab_below_navigation_toolbar_toolbox_top_padding_macOS: calc(-1px + var(--tab-min-height));
}

#TabsToolbar {
  order: 100;
  color: var(--toolbar-color);
}

#main-window:is([tabsintitlebar],[customtitlebar]):not([sizemode="fullscreen"]) #toolbar-menubar[inactive] ~ #nav-bar {
  padding-top: 24px !important;
}

#main-window:is([tabsintitlebar],[customtitlebar]) #toolbar-menubar {
  padding-inline-end: 140px;
}

#main-window:is([tabsintitlebar],[customtitlebar]) #toolbar-menubar:not([inactive]) {
  height: 24px !important;
}

#toolbar-menubar[autohide="true"] {
    :root:is([tabsintitlebar],[customtitlebar]) #navigator-toolbox:not([tabs-hidden]) > & {
      min-height: unset !important;
    }
}

/* move caption buttons to windows top right position */
.titlebar-buttonbox-container {
  position: fixed;
  right: 0;
  visibility: visible;
  display: block;
}

#main-window:is([tabsintitlebar],[customtitlebar]):not([sizemode="fullscreen"]) #toolbar-menubar[autohide="true"]:not([inactive="true"]) ~ #TabsToolbar,
#main-window:is([tabsintitlebar],[customtitlebar]):not([sizemode="fullscreen"]) #toolbar-menubar[autohide="false"] ~ #TabsToolbar {
  margin-top: 0px !important;
}

#main-window[sizemode="fullscreen"] #nav-bar {
  padding-inline-end: 140px !important;
}

@media (-moz-platform: macos) {

	#main-window:is([tabsintitlebar],[customtitlebar]):not([sizemode="fullscreen"]):not([inDOMFullscreen="true"]) #navigator-toolbox {
	  padding-top: var(--tab_below_navigation_toolbar_toolbox_top_padding_macOS);
	}

	#main-window:is([tabsintitlebar],[customtitlebar]):not([sizemode="fullscreen"]):not([inDOMFullscreen="true"]) .titlebar-buttonbox-container {
	  position: fixed;
	  top: 3px !important;
	  right: unset;
	  left: 0;
	  visibility: visible;
	  display: block;
	}

	:root[lwtheme] #titlebar {
	  background-image: var(--lwt-header-image, var(--lwt-additional-images));
	  background-repeat: var(--lwt-background-tiling);
	  background-position: var(--lwt-background-alignment);
	}

	/* caption button position in maximized mode after moving to the top */
	#main-window:is([tabsintitlebar],[customtitlebar]):not([inDOMFullscreen="true"]) #toolbar-menubar[autohide="true"] ~ #TabsToolbar .titlebar-buttonbox-container,
	#main-window:is([tabsintitlebar],[customtitlebar])[sizemode="maximized"]:not([inDOMFullscreen="true"]) #TabsToolbar .titlebar-buttonbox-container {
	  top: 0;
	}

	#main-window:is([tabsintitlebar],[customtitlebar])[sizemode="maximized"]:not([inDOMFullscreen="true"]) #titlebar {
	  height: 0px;
	}
}

/* remove unneeded items */
#TabsToolbar .titlebar-buttonbox-container,
#TabsToolbar #window-controls,
#TabsToolbar *[type="caption-buttons"],
#TabsToolbar *[type="pre-tabs"],
#TabsToolbar *[type="post-tabs"] {
  display: none;
}

/* lw themes support */
/* overrides other settings too */
:root:not([lwtheme]) #navigator-toolbox #TabsToolbar,
:root:not([lwtheme]):not(:is([tabsintitlebar],[customtitlebar])) #TabsToolbar{
  appearance: none !important;
}

@media not (-moz-toolbar-prefers-color-scheme: dark), not (prefers-color-scheme: dark) {
	:root:not([lwtheme]) #navigator-toolbox #TabsToolbar{
	  background-image: var(--tabs_toolbar_color_tabs_not_on_top) !important;
	}
}

#nav-bar {
  box-shadow: unset !important;
}

/* remove color overlay for lw-themes */
:root[lwtheme][style*='--lwt-header-image'] :is(#nav-bar,#PersonalToolbar,#TabsToolbar){
  background: unset !important;
}

/* adjust background color */
:root[lwtheme]:not([style*='--lwt-header-image']) :is(#toolbar-menubar, #TabsToolbar) {
  appearance: none !important;
  background-image: linear-gradient(var(--toolbar-bgcolor),var(--toolbar-bgcolor)) !important;
}

/* Fixes for projects other settings */
/* remove application/hamburger button in titlebar and tab toolbars start padding */
#main-window:is([tabsintitlebar],[customtitlebar])[sizemode="fullscreen"] #navigator-toolbox #PanelUI-button {
  visibility: collapse;
}

/* override code inside appbutton in titlebar code */
#main-window:is([tabsintitlebar],[customtitlebar]) #toolbar-menubar[autohide="true"][inactive="true"] ~ #TabsToolbar,
#main-window:is([tabsintitlebar],[customtitlebar])[sizemode="maximized"] #toolbar-menubar[autohide="true"][inactive="true"] ~ #TabsToolbar,
#main-window:is([tabsintitlebar],[customtitlebar])[sizemode="fullscreen"] #TabsToolbar,
#main-window[uidensity=compact]:is([tabsintitlebar],[customtitlebar]) #toolbar-menubar[autohide="true"][inactive="true"] ~ #TabsToolbar,
#main-window[uidensity=compact]:is([tabsintitlebar],[customtitlebar])[sizemode="maximized"] #toolbar-menubar[autohide="true"][inactive="true"] ~ #TabsToolbar,
#main-window:is([tabsintitlebar],[customtitlebar]):is([sizemode="normal"],[sizemode="maximized"],[sizemode="fullscreen"]) #navigator-toolbox #TabsToolbar {
  padding-inline-start: 0px !important;
  margin-inline-start: 0px !important;
}

/* remove restored border between navigation toolbar and tabs toolbar */
:root:not([lwtheme]) #nav-bar{
  box-shadow: unset !important;
}

/* notification position */
#tab-notification-deck,
#tab-notification-deck-template {
  order: 101;
  /*position: absolute;
  display: block;
  bottom: calc( -2 * var(--tab_below_navigation_toolbar_bottom_padding) + 8px );
  width: 100vw;*/
}

/* Fx 105+ */
:root:not([privatebrowsingmode=temporary]) :is(toolbarbutton, toolbarpaletteitem) + #tabbrowser-tabs,
:root[privatebrowsingmode=temporary] :is(toolbarbutton:not(#firefox-view-button), toolbarpaletteitem:not(#wrapper-firefox-view-button)) + #tabbrowser-tabs {
  border-inline-start: 0px solid color-mix(in srgb, currentColor 25%, transparent) !important;
}

:root:not([privatebrowsingmode=temporary]):not([firefoxviewhidden]) :is(#firefox-view-button, #wrapper-firefox-view-button) + #tabbrowser-tabs:not([overflow]) {
  padding-inline-start: 0 !important;
  margin-inline-start: 0 !important;
}

/* Fx 106+ *//*
#private-browsing-indicator-with-label {
  display: none !important;
}
*/

@media (-moz-platform: macos) {
	#main-window:is([tabsintitlebar],[customtitlebar]) #TabsToolbar {
	  padding-inline-end: 0px !important
	}

	/* draggable window */
	#main-window:is([tabsintitlebar],[customtitlebar]) toolbox#navigator-toolbox{
	  -moz-window-dragging: drag !important;
	}

	:is(#TabsToolbar, #nav-bar, #PlacesToolbar) {
	  -moz-window-dragging: no-drag !important;
	}	
}

/* Fx 126+ */
:root[lwtheme] #nav-bar {
  border-top: 0 !important;
}
